@use './variables.module.scss' as vars;

#app {

  .main-container {
    min-height: 100%;
    transition: margin-left .28s;
    margin-left: vars.$base-sidebar-width;
    position: relative;
  }

  .sidebarHide {
    margin-left: 0!important;
  }

  .sidebar-container {
    transition: width 0.28s;
    width: vars.$base-sidebar-width !important;
    height: 100%;
    position: fixed;
    font-size: 0px;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    overflow: hidden;
    /* 移除固定背景色，使用组件中的动态背景色 */
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    
    /* 不要强制设置背景色，让组件样式生效 */

    // reset element-ui css
    .horizontal-collapse-transition {
      transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
    }

    .scrollbar-wrapper {
      overflow-x: hidden !important;
    }

    .el-scrollbar__bar.is-vertical {
      right: 0px;
    }

    .el-scrollbar {
      height: 100%;
    }

    &.has-logo {
      .el-scrollbar {
        height: calc(100% - 50px);
      }
    }

    .is-horizontal {
      display: none;
    }

    a {
      display: inline-block;
      width: 100%;
      overflow: hidden;
    }

    .svg-icon {
      margin-right: 16px;
      color: #64748b;
      transition: all 0.3s ease;
    }

    .el-menu {
      border: none;
      height: 100%;
      width: 100% !important;
      background: transparent !important;
      padding: 8px;
      
      /* 移除所有固定背景色，让组件样式生效 */
      .el-menu-item,
      .el-sub-menu__title {
        background: transparent !important;
      }
    }

    .el-menu-item {
      border-radius: 8px;
      margin: 2px 0;
      transition: all 0.3s ease;
      /* 移除固定颜色，使用组件动态颜色 */
      font-weight: 500;
      background: transparent !important;
      
      /* 保留悬停效果但不强制背景色 */
      &:hover {
        transform: translateX(4px);
      }
      
      /* 保留激活状态效果 */
      &.is-active {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
      }
    }
    
    .el-sub-menu {
      .el-sub-menu__title {
        border-radius: 8px;
        margin: 2px 0;
        transition: all 0.3s ease;
        /* 移除固定颜色，使用组件动态颜色 */
        font-weight: 500;
        background: transparent !important;
        
        &:hover {
          transform: translateX(2px);
        }
      }
      
      .el-menu {
        background: rgba(248, 250, 252, 0.5);
        border-radius: 8px;
        margin: 4px 0;
        padding: 4px;
        
        .el-menu-item {
          margin: 1px 0;
          
          &:hover {
            background: rgba(102, 126, 234, 0.08) !important;
            transform: translateX(2px);
          }
        }
      }
    }

    .menu-title {
      overflow: hidden !important;
      text-overflow: ellipsis !important;
      white-space: nowrap !important;
    }

    .el-menu-item .el-menu-tooltip__trigger {
      display: inline-block !important;
    }

    // menu hover
    .sub-menu-title-noDropdown,
    .el-sub-menu__title {
      &:hover {
        background-color: rgba(102, 126, 234, 0.1) !important;
      }
    }

    & .theme-dark .is-active > .el-sub-menu__title {
      color: vars.$base-menu-color-active !important;
    }

    & .nest-menu .el-sub-menu>.el-sub-menu__title,
    & .el-sub-menu .el-menu-item {
      min-width: vars.$base-sidebar-width !important;

      &:hover {
        background-color: rgba(102, 126, 234, 0.08) !important;
      }
    }

    & .theme-dark .nest-menu .el-sub-menu>.el-sub-menu__title,
    & .theme-dark .el-sub-menu .el-menu-item {
      background-color: vars.$base-sub-menu-background;

      &:hover {
        background-color: vars.$base-sub-menu-hover !important;
      }
    }
  }

  .hideSidebar {
    .sidebar-container {
      width: 54px !important;
    }

    .main-container {
      margin-left: 54px;
    }

    .sub-menu-title-noDropdown {
      padding: 0 !important;
      position: relative;

      .el-tooltip {
        padding: 0 !important;

        .svg-icon {
          margin-left: 20px;
        }
      }
    }

    .el-sub-menu {
      overflow: hidden;

      &>.el-sub-menu__title {
        padding: 0 !important;

        .svg-icon {
          margin-left: 20px;
        }

      }
    }

    .el-menu--collapse {
      .el-sub-menu {
        &>.el-sub-menu__title {
          &>span {
            height: 0;
            width: 0;
            overflow: hidden;
            visibility: hidden;
            display: inline-block;
          }
          &>i {
            height: 0;
            width: 0;
            overflow: hidden;
            visibility: hidden;
            display: inline-block;
          }
        }
      }
    }
  }

  .el-menu--collapse .el-menu .el-sub-menu {
    min-width: vars.$base-sidebar-width !important;
  }

  // mobile responsive
  .mobile {
    .main-container {
      margin-left: 0px;
    }

    .sidebar-container {
      transition: transform .28s;
      width: vars.$base-sidebar-width !important;
    }

    &.hideSidebar {
      .sidebar-container {
        pointer-events: none;
        transition-duration: 0.3s;
        transform: translate3d(-(vars.$base-sidebar-width), 0, 0);
      }
    }
  }

  .withoutAnimation {

    .main-container,
    .sidebar-container {
      transition: none;
    }
  }
}

// when menu collapsed
.el-menu--vertical {
  &>.el-menu {
    .svg-icon {
      margin-right: 16px;
    }
  }

  .nest-menu .el-sub-menu>.el-sub-menu__title,
  .el-menu-item {
    &:hover {
      // you can use $sub-menuHover
      background-color: rgba(0, 0, 0, 0.06) !important;
    }
  }

  // the scroll bar appears when the sub-menu is too long
  >.el-menu--popup {
    max-height: 100vh;
    overflow-y: auto;

    &::-webkit-scrollbar-track-piece {
      background: #d3dce6;
    }

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-thumb {
      background: #99a9bf;
      border-radius: 20px;
    }
  }
}

// 暗黑模式下的sidebar样式
html.dark {
  #app .sidebar-container {
    background: #000000 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    
    .sidebar-logo-container {
      background: #000000 !important;
    }
    
    .el-scrollbar__wrap {
      background: #000000 !important;
    }
  }
  
  .main-container {
    background: #000000 !important;
  }
}